package com.ruoyi.project.WebMoudle.vipCoupon.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.WebMoudle.onlineCoupon.domain.MyCoupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.WebMoudle.vipCoupon.mapper.VipCouponMapper;
import com.ruoyi.project.WebMoudle.vipCoupon.domain.VipCoupon;
import com.ruoyi.project.WebMoudle.vipCoupon.service.IVipCouponService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 会员优惠券Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-07-09
 */
@Service
public class VipCouponServiceImpl implements IVipCouponService 
{
    @Autowired
    private VipCouponMapper vipCouponMapper;

    /**
     * 查询会员优惠券
     * 
     * @param id 会员优惠券ID
     * @return 会员优惠券
     */
    @Override
    public VipCoupon selectVipCouponById(Long id)
    {
        return vipCouponMapper.selectVipCouponById(id);
    }

    /**
     * 查询会员优惠券列表
     * 
     * @param vipCoupon 会员优惠券
     * @return 会员优惠券
     */
    @Override
    public List<VipCoupon> selectVipCouponList(VipCoupon vipCoupon)
    {
        return vipCouponMapper.selectVipCouponList(vipCoupon);
    }

    /**
     * 新增会员优惠券
     * 
     * @param vipCoupon 会员优惠券
     * @return 结果
     */
    @Override
    public int insertVipCoupon(VipCoupon vipCoupon)
    {
        vipCoupon.setCreateTime(DateUtils.getNowDate());
        return vipCouponMapper.insertVipCoupon(vipCoupon);
    }

    /**
     * 修改会员优惠券
     * 
     * @param vipCoupon 会员优惠券
     * @return 结果
     */
    @Override
    public int updateVipCoupon(VipCoupon vipCoupon)
    {
        vipCoupon.setUpdateTime(DateUtils.getNowDate());
        return vipCouponMapper.updateVipCoupon(vipCoupon);
    }

    /**
     * 删除会员优惠券对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteVipCouponByIds(String ids)
    {
        return vipCouponMapper.deleteVipCouponByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除会员优惠券信息
     * 
     * @param id 会员优惠券ID
     * @return 结果
     */
    @Override
    public int deleteVipCouponById(Long id)
    {
        return vipCouponMapper.deleteVipCouponById(id);
    }

    @Override
    public int addSomeEnety(ArrayList<VipCoupon> list) {
        return vipCouponMapper.addSomeEnety(list);
    }

    @Override
    public int queryMyCouponNum(Long wxUserId) {
        return vipCouponMapper.queryMyCouponNum(wxUserId);
    }

    @Override
    public List<MyCoupon> selectCouponList(Long wxUserId) {
        return vipCouponMapper.selectCouponList(wxUserId);
    }

    @Override
    public VipCoupon selectMyCoupon(Long couponId, Long wxUserId) {
        return vipCouponMapper.selectMyCoupon(couponId,wxUserId);
    }

    @Override
    public List<MyCoupon> selectUseList(Long wxUserId, Double beforePrice) {
        return vipCouponMapper.selectUseList(wxUserId,beforePrice);
    }

    @Override
    public int updateExpire() {
        return vipCouponMapper.updateExpire();
    }
}
